package com.ruoyi.web.controller.student;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.BaseSignalanalysisInfo;
import com.ruoyi.domain.BaseSignalanalysisInfoForS;
import com.ruoyi.service.IBaseSignalanalysisInfoForSService;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 信号分析Controller
 * 
 * @author ruoyi
 * @date 2025-06-08
 */
@RestController
@RequestMapping("/signalanalysis/signalanalysis")
public class BaseSignalanalysisInfoForsController extends BaseController
{
    @Autowired
    private IBaseSignalanalysisInfoForSService baseSignalanalysisInfoService;

    /**
     * 查询信号分析列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {
        startPage();
        Long userid = getUserId();
        baseSignalanalysisInfo.setUserId(userid);
        baseSignalanalysisInfo.setIsDel("0");
        List<BaseSignalanalysisInfoForS> list = baseSignalanalysisInfoService.selectBaseSignalanalysisInfoList(baseSignalanalysisInfo);
        return getDataTable(list);
    }


    @GetMapping("/getlist")
    public AjaxResult getlist(BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {

        if(baseSignalanalysisInfo.getUserId() == null){
            Long userid = getUserId();
            baseSignalanalysisInfo.setUserId(userid);
            baseSignalanalysisInfo.setIsDel("0");
        }

        List<BaseSignalanalysisInfoForS> list = baseSignalanalysisInfoService.selectBaseSignalanalysisInfoList(baseSignalanalysisInfo);
        return success(list);
    }

    /**
     * 导出信号分析列表
     */
    @Log(title = "信号分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {
        List<BaseSignalanalysisInfoForS> list = baseSignalanalysisInfoService.selectBaseSignalanalysisInfoList(baseSignalanalysisInfo);
        ExcelUtil<BaseSignalanalysisInfoForS> util = new ExcelUtil<BaseSignalanalysisInfoForS>(BaseSignalanalysisInfoForS.class);
        util.exportExcel(response, list, "信号分析数据");
    }

    /**
     * 获取信号分析详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(baseSignalanalysisInfoService.selectBaseSignalanalysisInfoById(id));
    }

    /**
     * 新增信号分析
     */
    @Log(title = "信号分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {
        Long userid = getUserId();
        String time = DateUtils.getTime();
        baseSignalanalysisInfo.setUserId(userid);
        baseSignalanalysisInfo.setcTime(time);
        baseSignalanalysisInfoService.insertBaseSignalanalysisInfo(baseSignalanalysisInfo);
        return success(baseSignalanalysisInfo.getId());
    }

    /**
     * 修改信号分析
     */
    @Log(title = "信号分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {
        String time = DateUtils.getTime();
        baseSignalanalysisInfo.setuTime(time);
        return toAjax(baseSignalanalysisInfoService.updateBaseSignalanalysisInfo(baseSignalanalysisInfo));
    }

    /**
     * 删除信号分析
     */
    @Log(title = "信号分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseSignalanalysisInfoService.deleteBaseSignalanalysisInfoByIds(ids));
    }


    /*信号分析更新状态 */

    @PostMapping("/updateStatus")
    public R updateStatus(@RequestBody List<Integer> id)
    {
      return R.ok(baseSignalanalysisInfoService.updateStatus(id));
    }


}
